//
//  ExpertListCellModel.m
//  EnvironmentalProtection
//
//  Created by HCreater on 2018/11/1.
//  Copyright © 2018年 HCreater. All rights reserved.
//

#import "ExpertListCellModel.h"

@interface ExpertListCellModel ()

@property (nonatomic, copy) NSString* name;
@property (nonatomic, copy) NSString* intro;
@property (nonatomic, copy) NSString* headimg;

@end

@implementation ExpertListCellModel

- (instancetype)initWithData:(id)data cellHeight:(CGFloat)cellHeight
{
    self = [super init];
    if (self)
    {
        _data = data;
        
        /// cellHeight+2（2容错）
        _cellHeight = MHUIScaleValue(cellHeight)+2;
        
        ExpertListData* curData = _data;
        
        self.name = curData.nickName;
        self.intro = curData.summary;
        self.headimg = curData.headImg;
        
        @weakify(self);
        self.expertCommand = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(id input)
                              {
                                  @strongify(self);
                                  
                                  @weakify(self);
                                  return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber)
                                          {
                                              @strongify(self);
                                              
                                              [subscriber sendNext:curData.userID];
                                              [subscriber sendCompleted];
                                              
                                              return nil;
                                          }];
                              }];
        
        self.consultCommand = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(id input)
                               {
                                   @strongify(self);
                                   
                                   @weakify(self);
                                   return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber)
                                           {
                                               @strongify(self);
                                               
                                               [subscriber sendNext:curData.expertID];
                                               [subscriber sendCompleted];
                                               
                                               return nil;
                                           }];
                               }];
    }
    
    return self;
}

@end
